<% layout('/layout/default.html', {title: '已办任务', libs: ['dataGrid','icheck']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="card-header">
			<i class="fa fa-sitemap"></i> 已办任务
			<div class="header-tools float-right">
				<a href="#" class="btn btn-default btn-sm" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
			</div>
		</div>
		<div class="container-fluid">
			<form id="searchForm" action="${ctx}/act/task/historicData" class="form-inline d-none">
				<div class="form-group">
					<label class="control-label">流程分类：</label>
					<div class="control-inline">
						<#form:select path="category" name="label" data="getDictList:act_category" class="form-control select2bs4" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">发起人：</label>
					<div class="control-inline">
						<#form:select id="userid" path="startBy" name="name" value="loginName" data="${userList}" class="form-control select2bs4" />
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">办理日期：</label>
					<div class="control-inline">
						<input id="beginDate" name="beginDate" maxlength="64" readonly="readonly" class="form-control form-control-sm"
							   value="" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});" /> -
						<input id="endDate" name="endDate" maxlength="64" readonly="readonly" class="form-control form-control-sm"
							   value="" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});" />
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-success btn-sm">查询</button>
					<button id="reset" type="reset" class="btn btn-default btn-sm">重置</button>
				</div>
			</form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
	$.fn.select2.defaults.set('width', '200px');
	$('#reset').click(function(){
		$('#category').val(null).trigger("change");
		$('#userid').val(null).trigger("change");
		$('#isFinish').val(null).trigger("change");
	});
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{header:'流程名称', name:'procDefname', index:'procDefname', width:100, align:"center"},
			{header:'流程发起人', name:'startUser.name', index:'', width:80, align:"center" },
			{header:'已办环节', name:'taskName', index:'', width:90, align:"center",formatter: function(val, obj, row, act){
					return row.processIsFinished=="finished"?'<a href="${ctx}/act/task/diagramViewer?definitionId='+row.procDefId+ '&hisInsId=' + row.procInsId + '" class="btnList" title="流程图查看" data-type="diagram">' +val+ '</a>':'<a href="${ctx}/act/task/diagramViewer?definitionId='+row.procDefId+ '&instanceId=' + row.procInsId + '" class="btnList" title="流程图查看" data-type="diagram">' +val+ '</a>';
				}},
			{header:'办理时间', name:'hisTaskEndTime', index:'hisTaskEndTime', width:100, align:"center", formatter:"date",formatoptions:{srcformat: 'Y-m-d H:i:s',newformat: 'Y-m-d H:i:s'} },
			{header:'流程状态', name:'processIsFinished', width:50, align:"center",formatter: function(val, obj, row, act){
					var state;
					if (row.processIsFinished=="finished") {
						state = "已结束";
					} else if(row.processIsFinished=="delete") {
						state = "已删除";
					} else {
						state = "未结束";
					}
					return state;
				}},
			{header:'操作', name:'actions', width:100, sortable:false, title:false, align:"center",formatter: function(val, obj, row, act){
					var actions = [];
				<% if(hasPermi('act:process:edit')){ %>
						actions.push('<a href="/act/flowForm/common?taskDefKey='+row.taskDefKey+'&procInsId='+row.procInsId+'&procDefId='+row.procDefId+'&status='+row.status+' " class="btnList" title="详情查看" ><i class="fab fa-elementor"></i>&nbsp;</a>')
						<% } %>
					return actions.join('');
				}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});
</script>